package com.example.smartcity.ui.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.smartcity.R;
import com.example.smartcity.ui.Bean.CitySubwayBean;

import java.util.List;

public class CitySubwayLVAdapter extends ArrayAdapter<CitySubwayBean.RowsBean> {
    List<CitySubwayBean.RowsBean> list;
    private int resource;
    public CitySubwayLVAdapter(@NonNull Context context, int resource, @NonNull List<CitySubwayBean.RowsBean> objects) {
        super(context, resource, objects);
        this.resource = resource;
        this.list = objects;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View view = LayoutInflater.from(getContext()).inflate(resource,parent,false);
        TextView TV_lineName = view.findViewById(R.id.TV_lineName);
        TextView TV_lastName = view.findViewById(R.id.TV_lastName);
        TextView TV_reachTime = view.findViewById(R.id.TV_reachTime);
        TV_lineName.setText(list.get(position).getLineName());
        TV_lastName.setText("下一站： "+list.get(position).getLastName());
        TV_reachTime.setText(list.get(position).getReachTime()+"分钟后");
        return view;
    }
}
